/******************************************************************************/
/*  Class LOG                                                                 */
/*  PO: S. Maslyakov, rusoil.9@gmail.com                                      */
/*                                                                            */
/*  Revision:     1.2                                                         */
/*  Date:         2011/03/26 22:28:33                                         */
/******************************************************************************/


#ifndef __LOG_H
#define __LOG_H


#include "Fmem_layer\fmem_layer.h"
#include "Log\log_def.h"


//==============================================================================
//  Class LOG
//==============================================================================
class LOG : public FMEM_LAYER
{

public:
  LOG(__TOOLS_BRAM_LOG * const _pTools) : m_pTools(_pTools),
                                          m_timePeriod(0),
                                          m_recSize(0),
                                          m_cutOff(0),
                                          m_isLogInit(0) {}

  inline uint32_t GetRecSize() const { return (m_recSize + sizeof(__HEADER_LOG)); }
  inline uint32_t GetTimePeriod() const { return m_timePeriod; }
  inline uint32_t IsLogInit() const { return m_isLogInit; }
  void InitLog(const __SETT_HEADER_LOG * const _pSett, const uint32_t _addr);
  void ClearLog();
  void ClearDots(const uint32_t _numDot);
  uint32_t GetTile() const;
  uint32_t GetHead() const;
  uint32_t GetRecNum() const;
  uint32_t GetLogSize() const;
  uint32_t GetFreeMemory() const;
  bool_t NeedSendLog() const;
  uint32_t WriteRec(const void * const _pData);
  uint32_t ReadRec(const uint32_t _recNum, uint8_t * const _pDst);

private:
  void IncTile();
  void IncHead();
  void IncRecNum();
  uint32_t IncLogAddr(const uint32_t _addr) const;
  bool_t IsLogOverflow() const;

  __TOOLS_BRAM_LOG * const m_pTools;
  uint32_t m_isLogInit;
  uint32_t m_timePeriod;
  uint32_t m_recSize;
  uint32_t m_cutOff;
};
//==============================================================================
//==============================================================================



#endif